package io.gitee.xyuesheng.day05;

import java.util.Objects;

public class Student {
    private String name;
    private int age;
    private String sno;

    public Student() {

    }

    public Student(String name, int age, String sno) {
        this.name = name;
        this.age = age;
        this.sno = sno;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSno() {
        return sno;
    }

    public void setSno(String sno) {
        this.sno = sno;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("HomeworkStudent{");
        sb.append("name='").append(name).append('\'');
        sb.append(", age=").append(age);
        sb.append(", sno='").append(sno).append('\'');
        sb.append('}');
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        //要判断当前对象的属性  是否 和另外对象的属性一一相等

        if (obj == null) {
            return false;
        }

        //obj不是student的一个实例
        if (!(obj instanceof Student)) {
            return false;
        }

        Student other = (Student) obj;

        if (Objects.equals(this.name, other.name)) {

        }

        if (!this.name.equals(other.name)) {
            return false;
        }
        if (this.age != (other.age)) {
            return false;
        }
        if (!this.sno.equals(other.sno)) {
            return false;
        }
        return true;


    }
}
